#!/usr/bin/env python3
# -*- coding: utf-8 -*-
# @Time    : 2021/6/14 
# @Author  : Mik
import requests

# from string import Template
# from common.read_config import load


# def exec_func(func: str) -> str:
#     """执行函数(exec可以执行Python代码)
#     :params func 字符的形式调用函数
#     : return 返回的将是个str类型的结果
#     """
#     # 得到一个局部的变量字典，来修正exec函数中的变量，在其他函数内部使用不到的问题
#     loc = locals()
#     exec(f"result = {func}")
#     return str(loc['result'])
#
#
# def rep_expr(content: str, data: dict) -> str:
#     """从请求参数的字符串中，使用正则的方法找出合适的字符串内容并进行替换
#     :param content: 原始的字符串内容
#     :param data: 提取的参数变量池
#     return content： 替换表达式后的字符串
#     """
#     content = Template(content).safe_substitute(data)
#     for func in re.findall('\\${(.*?)}', content):
#         try:
#             content = content.replace('${%s}' % func, exec_func(func))
#         except:
#             raise
#     return content
#
# data= load('register.yaml')
# # print(data['case1'])
#
# str = '{"username": "${username}", "password": "${password}", "sex": "${sex}", "telephone":"${phone}", "address": "${add}"}'
# # data = {'username': 'test12212', 'password': 123456}
#
# r = rep_expr(str, data['case1'])
# print(r,type(r))

# def send_request(ids=None, header=None, data=None):
#     if ids is not None:
#         url = '123' + ids
#
#         print(url)
#
# send_request(ids='456')

# r= requests.get('https://httpbin.testing-studio.com/get')
# print(r)

from jsonschema import validate

schema = {
    "type": "object",
    "properties": {
        "price": {"type": "number"},
        "name": {"type": "number"},
    },
}
validate(instance={"name": "Eggs", "price": 34.99}, schema=schema)
